﻿<%@ Page Title="Manage Mentors" Language="C#" MasterPageFile="/Administration/Site.Master" AutoEventWireup="true" CodeBehind="EditMentor.aspx.cs" Inherits="AdministrationWeb.Administration.EditMentor" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="headerText" runat="server">
    Manage Mentors
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    &nbsp;<br />
    <br />
    <br />
    First Name&nbsp;
    <asp:TextBox ID="txtFirstName" runat="server" Width="300" />
    <br />
    Last Name&nbsp;
    <asp:TextBox ID="txtLastName" runat="server" Width="300" />
    <br />
    Pathway&nbsp;
    <asp:DropDownList ID="ddlPathway" DataSourceID="SqlPathwayDropdown" AutoPostBack="false" DataValueField="pathway_name" runat="server" Width="300px" AppendDataBoundItems="true">
        <asp:ListItem Text="All" Value="%" />
    </asp:DropDownList>
    <br />
    <br />
    <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search" CssClass="button" />
    &nbsp;&nbsp; &nbsp;&nbsp;
    <br />
    <br />
    <br />
    <asp:Label ID="lblError" runat="server" Text="" Visible="False" ForeColor="red" /> 
    <asp:SqlDataSource ID="SqlMentors" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationConnectionString %>" ProviderName="<%$ ConnectionStrings:ApplicationConnectionString.ProviderName %>"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT m.mentor_id, m.first_name, m.last_name, p.pathway_name, m.email
                        FROM mentor m, lkup_pathway p
                        WHERE LCASE(first_name) LIKE LCASE(CONCAT(?FirstName, '%'))
                        AND LCASE(last_name) LIKE LCASE(CONCAT(?LastName, '%'))
                        AND deletion_date IS null
                        AND p.pathway_id = m.pathway_id
                        ORDER BY last_name, first_name" ConflictDetection="CompareAllValues" DeleteCommand="UPDATE mentor
                                                            SET deletion_date = NOW(), deletion_user_id = ?delete_id
                                                            WHERE mentor_id = ?original_mentor_id" FilterExpression="pathway_name like '{0}%'">
        <DeleteParameters>
            <asp:Parameter Name="original_mentor_id" />
            <asp:Parameter Name="original_mentor_name" />
            <asp:ControlParameter ControlID="lblUserId" DefaultValue="" Name="delete_id" PropertyName="Text" />
        </DeleteParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="txtFirstName" DefaultValue="%" Name="FirstName" PropertyName="Text" />
            <asp:ControlParameter ControlID="txtLastName" DefaultValue="%" Name="LastName" PropertyName="Text" />
        </SelectParameters>
        <FilterParameters>
            <asp:ControlParameter Name="lkup_pathway" ControlID="ddlPathway" PropertyName="SelectedValue" />
        </FilterParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlPathwayDropdown" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationConnectionString %>" ProviderName="<%$ ConnectionStrings:ApplicationConnectionString.ProviderName %>"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT p.pathway_id, p.focus_id, p.pathway_name
                        FROM lkup_pathway p
                        ORDER BY pathway_name" ConflictDetection="CompareAllValues"></asp:SqlDataSource>
    <asp:GridView ID="gdvMentors" runat="server" DataSourceID="SqlMentors" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BorderColor="#006600"
        BorderStyle="Double" CellPadding="4" ForeColor="#333333" OnRowDeleted="gdvMentors_RowDeleted" OnSelectedIndexChanged="gdvMentors_SelectedIndexChanged"
        Visible="False" DataKeyNames="mentor_id">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField SelectText="Edit" ShowSelectButton="True" ButtonType="Button">
                <ControlStyle CssClass="button" />
            </asp:CommandField>
            <asp:ButtonField ButtonType="Button" CommandName="Delete" Text="Delete">
                <ControlStyle CssClass="button" />
            </asp:ButtonField>
            <asp:BoundField DataField="mentor_id" HeaderText="Id" ReadOnly="True" DataFormatString="{0:d}" Visible="False">
                <ItemStyle HorizontalAlign="Center" Width="100px" />
            </asp:BoundField>
            <asp:BoundField DataField="last_name" HeaderText="Last" />
            <asp:BoundField DataField="first_name" HeaderText="First" />
            <asp:BoundField DataField="pathway_name" HeaderText="Pathway" />
            <asp:BoundField DataField="email" HeaderText="Email" />
        </Columns>
        <EditRowStyle BackColor="#7C6F57" />
        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#E3EAEB" />
        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F8FAFA" />
        <SortedAscendingHeaderStyle BackColor="#246B61" />
        <SortedDescendingCellStyle BackColor="#D4DFE1" />
        <SortedDescendingHeaderStyle BackColor="#15524A" />
    </asp:GridView>
    <br />
    <asp:Label ID="lblUserId" runat="server" Visible="False"></asp:Label>
    <br />
    <asp:Label ID="lblMessage" runat="server" Font-Italic="True" Font-Size="Smaller" ViewStateMode="Enabled"></asp:Label>
    <br />
</asp:Content>
